<template>
    <div class="container">
        <p>点击次数number：{{$store.state.count}}</p>
        <p>现在是{{oddOrEven}}</p>
        <button @click="handleAdd">加1步</button>
        <button @click="handleAdd2">加2步</button>
        <button @click="handleJian">减</button>
        <button @click="handleAddOdd">只有是奇数的时候才增加</button>
        <button @click="handleAddAsync">异步增加点击增加</button>
    </div>
</template>

<script>
    export default {
        name: "App",
        data () {
            return {}
        },
        computed:{
            oddOrEven () {
                return this.$store.getters.evebOrOdd
            }
        },
        methods:{
            handleAdd () {
                // this.count++;
                this.$store.dispatch('handleAdd')
            },
            handleAdd2 () {
                // this.count++;
                this.$store.dispatch('handleAdd',2)
            },
            handleJian () {
                // this.count--;
                this.$store.dispatch('handleJian')
            },
            handleAddOdd () {
                // if(this.count%2!=0){
                //     this.count++;
                // }
                this.$store.dispatch('handleAddOdd')
            },
            handleAddAsync () {
                // setTimeout(() => {
                //     this.count++
                // },1000)
                this.$store.dispatch('handleAddAsync')
            }
        }

    }
</script>

<style lang="stylus" scoped>
</style>